import { createRouter, createWebHistory } from 'vue-router'
import { cleanReq } from '../axioser'
import Common from '../layouts/Common.vue'
const routes = [
  {
    path: '/',
    redirect: '/dashboard',
  },
  {
    path: '/',
    name: 'Home',
    component: Common,
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        meta: {
          title: '主面板',
        },
        component: () => import('../views/Dashborad.vue'),
      },
      {
        path: '/my-account',
        name: 'my-account',
        meta: {
          title: '我的账号',
        },
        component: () => import('../views/account/MyAccount.vue'),
      },
      {
        path: '/others-account',
        name: 'others-account',
        meta: {
          title: '账号列表',
        },
        component: () => import('../views/account/OtherAccount.vue'),
      },
      {
        path: '/wx-vip',
        name: 'vip',
        meta: {
          title: '会员',
        },
        component: () => import('../views/wechat/Vip.vue'),
      },
      {
        path: '/wx-interface',
        name: 'wx-interface',
        meta: {
          title: '微信接口',
        },
        component: () => import('../views/wechat/_Interface.vue'),
      },
      {
        path: '/points',
        name: 'points',
        meta: {
          title: '积分管理',
        },
        component: () => import('../views/control/points/Points.vue'),
      },
      {
        path: '/goods',
        name: 'goods',
        meta: {
          title: '商品管理',
        },
        component: () => import('../views/control/shop/index.vue'),
      },
      //   {
      //     path: '/404',
      //     name: '404',
      //     meta: {
      //       title: '找不到页面',
      //     },
      //     component: () => import('../views/404.vue'),
      //   },
      //   {
      //     path: '/403',
      //     name: '403',
      //     meta: {
      //       title: '没有权限',
      //     },
      //     component: () => import('../views/403.vue'),
      //   },
    ],
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录',
    },
    component: () => import('../views/Login.vue'),
  },
]
const router = createRouter({
  history: createWebHistory(),
  routes,
})

// 清空多余请求
router.beforeEach((to, from, next) => {
  cleanReq()
  next()
})
export default router
